package com.SmartWallet.models;

import java.util.*;
import java.io.*;

public class BudgetList implements Serializable{
	
	private String name;
	private ArrayList<ListEntry> entries;
	private int budget, expenses, warning;
	
	public BudgetList(String name, int budget, int warning)
	{
		this.name = name;
		this.budget = budget;
		this.warning = warning;
		entries = new ArrayList<ListEntry>();
	}
	
	public BudgetList(String name, int budget)
	{
		this.name = name;
		this.budget = budget;
		this.warning = 0;
		entries = new ArrayList<ListEntry>();
	}
	
	public BudgetList(String name)
	{
		this.name = name;
		budget = 0;
		warning = 0;
		entries = new ArrayList<ListEntry>();
	}
	
	public void addEntry(ListEntry entry)
	{
		entries.add(entry);
	}
	
	public ListEntry deleteEntry(int index)
	{
		return entries.remove(index);
	}
	
	public ListEntry getEntry(int i)
	{
		return entries.get(i);
	}
	
	public String getName()
	{
		return name;
	}
	
	public int getBalance()
	{
		return budget - expenses;
	}
	
	public int getExpenses()
	{
		return expenses;
	}
	
	public int getWarning()
	{
		return warning;
	}
	
	public int getBudget()
	{
		return budget;
	}
	
	public ArrayList<ListEntry> getEntries()
	{
		return entries;
	}
	
	public void updateExpenses()
	{
		expenses = 0;
		for(int i = 0; i < entries.size(); i++)
		{
		
			expenses = expenses + entries.get(i).getCost();
		}
	}
	
	

}
